﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="format-detection" content="telephone=no" />
    <title>提币</title>
    <link rel="stylesheet" href="css/style.css?v=1.0">
    <link rel="stylesheet" href="css/index.css?v=1.0">
    <script src="js/jquery-1.8.3.min.js"></script>
    <script src="js/flexible.js?v=1.0"></script>
    <script src="layer-mobile/layer.js?v=1.0"></script>
</head>
<body>
    <header id="header">
        <div class="back" onclick="closeWin();">
            <img src="image/back.png">
        </div>
        <div class="title">提币</div>
    </header>

    <form id="form1">
        <div class="mention">
            <div class="men-list">
                <label>币种选择： </label> <select id="drpAssetId"></select>
            </div>
            <div class="men-list">
                <label>提现数量：</label><input id="txtTransCredit" type="number" />
            </div>

            <div class="men-list">
                <label>钱包地址：</label> <select id="drpWallets"></select>
            </div>
            <p class="men-des">1.用户拥有代币，显示在“我的资产”中，用户需要提币时，需要准备好自己的提币钱包（即以太坊钱包）地址。如没有钱包，可以通过以太坊官方钱包或第三方“imtoken”APP生成钱包地址。</p>
            <p class="men-des">2.原则用户每周能“提币”一次，用户不“提币”也不影响账户资产。某些代币有最低提币限额，只有当前申请提币数量必须大于等于“最低提币限额”才可以申请提币。</p>
            <p class="men-des">3.需要“提币”时，在提币页面的“币种选择”选择你要提取的代币类型，填取提币金额，在“钱包地址”选择你绑定的钱包（即以太坊钱包）地址。检查无误后点击“提交”，经后台复核后相应代币转入到你的钱包。</p>

            <div class="men-btn">
                <input id="btnSubmit" type="button" value="提交" />
            </div>

        </div>
       
    </form>

</body>

</html>
<script type="text/javascript">
    $(document).ready(function () {

        $("#btnSubmit").click(function () {
            var myUserID = getUserId();
            $.ajax({
                type: "POST",
                url: "/API/AjaxHandler.ashx?Action=KongtouWeb.UserWalletsAjax.SaveNewTransOut",
                data: {
                    userId: myUserID,
                    assetId: $("#drpAssetId").val(),
                    walletId: $("#drpWallets").val(),
                    transCredit: $("#txtTransCredit").val()
                },
                async: false,
                error: function (request) {
                    layer.open({
                        content: '系统异常',
                        skin: 'msg',
                        time: 2
                    });
                },
                success: function (data) {
                    if (data.status == "1")
                    {
                        layer.open({
                            content: '提币申请提交成功',
                            btn: ['确定'],
                            yes: function (index) {
                                window.location.href = "/user.html";
                            }
                        });
                    }
                    else
                    {
                        layer.open({
                            content: data.message,
                            btn: ['确定'],
                            yes: function (index) {
                                layer.close(index);
                            }
                        });
                    }

                }
            });
        })


        LoadDropList();

    });
    

    function LoadDropList() {
        var myUserID = getUserId();

        //加载币种
        $.ajax({
            type: "get",
            url: url + "getMyAssetsList.ashx",
            data: {
                userId: myUserID
            },
            dataType: 'json',
            error: function (request) {
                layer.open({
                    content: '系统异常',
                    skin: 'msg',
                    time: 2
                });
            },
            success: function (d) {
                var asset = d.data.assetsList;
                if (asset.length > 0)
                {
                    BindDropControl(asset, "drpAssetId", "currencyCode", "id");
                    InsertDropOption("drpAssetId", "请选择币种", "")
                }
            }
        });

        //加载钱包
        $.ajax({
            type: "get",
            url: url + "getMyWalletsList.ashx",
            data: {
                userId: myUserID
            },
            dataType: 'json',
            error: function (request) {
                layer.open({
                    content: '系统异常',
                    skin: 'msg',
                    time: 2
                });
            },
            success: function (d) {
                var wallets = d.data.walletsList;
                if (wallets.length > 0) {
                    BindDropControl(wallets, "drpWallets", "tag", "id");
                    InsertDropOption("drpWallets", "请选择提币钱包地址", "")
                }
            }
        });
    }
</script>